﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;

using Com.Framework;
using Com.Framework.Data;
using Com.Library.DB.Store;
using Com.Web.coffinegurunaru.AppLogic.Page;

namespace Com.Web.coffinegurunaru.store
{
	public partial class new_store : WebPage
	{
		public int StoreNo
		{
			get;
			set;
		}

		public StoreBestEntity BestStore
		{
			get;
			set;
		}

		public List<StoreBestEntity> BestStoreList
		{
			get;
			set;
		}

		public List<StoreImageEntity> StoreImageList
		{
			get;
			set;
		}

		protected void Page_Load(object sender, EventArgs e)
		{
			this.LeftMenuType = 1;
			StoreNo = Request.QueryString["StoreNo"].Parse(0);
			if (StoreNo == 0)
			{
				ListData<StoreBestEntity, OutputEntity> result = StoreModel.BestGetList(1, 1);
				if (result.Record.Count == 0)
				{
					Response.Clear();
					Response.Write("<script language='javascript'>alert('신규 매장이 존재하지 않습니다.'); location.href='/store/search_store.aspx';</script>");
					Response.End();
				}
				else
				{
					BestStoreList = StoreModel.BestGetList(1, 30).Record;
					BestStore = result.Record[0];
					StoreImageList = StoreModel.ImageGetList(BestStore.StoreNo, 5);
				}
			}
			else
			{
				BestStore = StoreModel.BestGetInfo(StoreNo);
				if (BestStore.CreateDate == DateTime.MinValue)
				{
					Response.Clear();
					Response.Write("<script language='javascript'>alert('존재하지 않는 신규 매장입니다.'); location.href='/store/search_store.aspx';</script>");
					Response.End();
				}
				else
				{
					BestStoreList = StoreModel.BestGetList(1, 30).Record;
					StoreImageList = StoreModel.ImageGetList(BestStore.StoreNo, 5);
				}
			}

			if (BestStore == null)
				BestStore = new StoreBestEntity();
		}
	}
}
